package creditcard;

import framework.account.AAccountObserver;
import framework.account.IAccount;
import framework.account.IEntry;
import framework.mvc.FincoContext;

public class CCAccountObserver extends AAccountObserver {

    public CCAccountObserver(IAccount account) {
        super(account);
    }

    @Override
    protected void successAction(IAccount account, IEntry iEntry) {
        //update UI: account balance
        FincoContext.getView().getViewModel().setValueAt(account.getBalance(), FincoContext.getView().getRowSelectedIndex(), 4);

        if (iEntry.getAmount() > 400 || account.getBalance() < 0) {
            CCardService.sendEmail(account);
        }
    }

    @Override
    protected void failAction(IAccount account, IEntry iEntry) {
        //TODO implement
    }
}